//
// The resource management layer has been upgraded, thus deprecating this file.
//
#error *** hashtabl.h has been deprecated. ***

#ifndef HASHTABL_H
#define HASHTABL_H


//----------------------------------------------------------------------------
// CHashTable stuff...

typedef uint32	(*CHashTableHashFunc)(char *);
typedef void	(*CHashTableDeleteFunc)(pCHashTable, void *, void *);
typedef void	(*CHashTableIterateFunc)(pCHashTable, void *, void *);

typedef struct _CHashTable
{
	CHashTableHashFunc			cHashFunc;
	CHashTableDeleteFunc		cDeleteFunc;
	void *						cUserData;
	uint32						cTableSize;

	// CHashTableIterate overhead...
	uint32						cIterateIndex;
	pCHashTableEntry			cIterateNext;

	// HashTable..._do not_ put anything after this line...
	pCHashTableEntry 			cTable[1];
} CHashTable;


PLIBEXP pCHashTable	newCHashTable(uint32 NumEntries, 
						CHashTableDeleteFunc DeleteFunc, void * UserData,
						CHashTableHashFunc HashFunc);
PLIBEXP void			deleteCHashTable(pCHashTable This);
void				CHashTableConstruct(pCHashTable This, uint32 NumEntries,
						CHashTableDeleteFunc DeleteFunc, void * UserData,
						CHashTableHashFunc HashFunc);
void				CHashTableDestruct(pCHashTable This);


PLIBEXP void			CHashTableFlush(pCHashTable);

PLIBEXP void			CHashTableIterateTable(pCHashTable This,
						CHashTableIterateFunc IterateFunc);
PLIBEXP void *		CHashTableIterate(pCHashTable This, bool8 Reset);
PLIBEXP pCHashTable	CHashTableResizeTable(pCHashTable This, uint32 NewSize);

PLIBEXP bool8			CHashTableAddDataByName(pCHashTable This, char * Name, 
						void * Data);
PLIBEXP bool8			CHashTableAddDataByID(pCHashTable This, uint32 ID,
						void * Data);
PLIBEXP void			CHashTableRemoveDataByName(pCHashTable This, char * Name);
PLIBEXP void			CHashTableRemoveDataByID(pCHashTable This, uint32 ID);
PLIBEXP void *		CHashTableGetDataByName(pCHashTable This, char * Name);
PLIBEXP void *		CHashTableGetDataByID(pCHashTable This, uint32 ID);

#define				CHashTableUserData(This)		((This)->cUserData)


// protected
bool8				CHashTableAddEntry(pCHashTable This,
						pCHashTableEntry Entry);
void				CHashTableRemoveEntry(pCHashTable This, uint32 ID);
pCHashTableEntry	CHashTableGetEntry(pCHashTable This, uint32 ID);

#define				CHashTableHashFunc(This)		((This)->cHashFunc)
#define				CHashTableDeleteFunc(This)		((This)->cDeleteFunc)
#define				CHashTableTableSize(This)		((This)->cTableSize)
#define				CHashTableTable(This)			((This)->cTable)


// Some internal functions that can be used...
PLIBEXP uint32		CHashTableHashFunction(char * Name);
void				CHashTableDeleteFunction(pCHashTable, void *, void *);


//----------------------------------------------------------------------------
// Private CHashTableEntry stuff.

typedef struct _CHashTableEntry
{
	uint32				cHashID;	
	void *				cData;
	pCHashTableEntry	cNext;
} CHashTableEntry;


pCHashTableEntry	newCHashTableEntry(uint32 ID, void * Data);
void				deleteCHashTableEntry(pCHashTableEntry This);
void				CHashTableEntryConstruct(pCHashTableEntry This, 
						uint32 ID, void * Data);
void				CHashTableEntryDestruct(pCHashTableEntry This);

#define CHashTableEntryHashID(This)		((This)->cHashID)
#define CHashTableEntryData(This)		((This)->cData)
#define CHashTableEntryNext(This)		((This)->cNext)


#endif
